from django.db import models

from lib import BaseModel


# Create your models here.
# 【3】作者表
class Author(BaseModel):
    name = models.CharField(max_length=32, verbose_name="作者名字")
    age = models.IntegerField(verbose_name="作者年龄")
    gender = models.IntegerField(choices=(
        (0, "女"),
        (1, "男"),
        (2, "保密"),
    ), default=2, verbose_name="作者性别")

    # 作者一对一作者详情
    detail = models.OneToOneField(to='AuthorDetail', on_delete=models.CASCADE, null=True)

    class Meta:
        db_table = "author"


# 【4】作者详情表
class AuthorDetail(BaseModel):
    phone = models.CharField(max_length=11, verbose_name="作者电话")
    email = models.EmailField(verbose_name="作者邮箱")
    addr = models.CharField(max_length=64, verbose_name="作者地址")

    class Meta:
        db_table = "author_detail"
